import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {Validators, FormBuilder,FormGroup} from '@angular/forms';  //要引入这3个


/**
 * Generated class for the CeshiPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.             //controller层去   scope化
 */
@IonicPage()       //自動上生成的     //路由还没写
@Component({
  selector: 'page-ceshi',
   templateUrl: 'ceshi.html',
})
export class CeshiPage {
    todo1:FormGroup;  //这里外面指定一个todo1 的类型
    todo = {};
    logForm() {
    console.log(this.todo);
    //传统提交表单的写法
    }

  constructor(public navCtrl: NavController, public navParams: NavParams,private formBuilder: FormBuilder) {
    //表单的内容写在这里面?
   this.todo1 = this.formBuilder.group({   
            title: ['', Validators.required],
            description: [''],
        });
  }
   

    ionViewLoaded() {
     
    }
    logForm1(){
       console.log(this.todo1.value) //formGroup自带value
    }

    unableSub(){
      // console.log('type of todo1',typeof(this.todo1));
   
       return  !this.todo1.value.title|| !this.todo1.value.description;
  //console.log(this.todo1);
      // return  !this.todo1.title||  !this.todo1.description ;
    }

  // ionViewDidLoad() {
  //   console.log('ionViewDidLoad CeshiPage');
  // }

}
